<?php
/*
 * Created on Jul 15, 2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<div class="link2node">
<?php
if (intval($content['fid'])){
	// Using model to get more information
	$CI =& get_instance();
	$this->load->model('Model_link2node', 'model_link2node');
	$link2node = $CI->model_link2node->find($content['fid']);

	if (!empty($link2node['nodelink'])){
		$show_title = $link2node['show_title'];
		$show_content = $link2node['show_content'];
		$show_sublevel = $link2node['show_sublevel'];
		$show_template = $link2node['show_template'];
		$show_sublevel_template = $link2node['show_sublevel_template'];
		// parse link
		$url = $link2node['nodelink'];
		$arr = parse_url($url);
		// parse query
		if(!empty($arr["query"])){
			$parameters = $arr["query"];
			$data = array();
			parse_str($parameters, $data);
			if ((isset ($data['l1'])) && ($data['l1'] != ""))
				$navid = $data['l1'];
			if ((isset ($data['l2'])) && ($data['l2'] != ""))
				$navid = $data['l2'];
			if ((isset ($data['l3'])) && ($data['l3'] != ""))
				$navid = $data['l3'];
			if ((isset ($data['l4'])) && ($data['l4'] != ""))
				$navid = $data['l4'];

			// Get thong tin node lien quan
			$node = $this->model_nav->find($navid);
			$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0;

			?>
			<?php if($show_title):?>
			<div class="show_title">
				<a class="nodeajax<?= $node['id'] == $cid ? " active" : ""?>" rel="#content_<?=$node['id']?>" href="<?=site_url($link2node['nodelink']."&m=getNodeInfor")?>"><?=$node['head']?></a>
			</div>
			<?php endif; ?>
			<?php if($show_content):?>
			<div class="show_content" id="content_<?=$node['id']?>">
				<?=$node['des']?><div class="clearfix"></div>
			</div>
			<?php endif; ?>
			<?php if($show_sublevel):?>
			<div class="show_sublevel">
				<?php
					$subsnode = $this->model_nav->fetchNav(null, 1, null, $node['id']);
				?>
				<ul>
				<?php foreach($subsnode as $key => $val):?>
					<li><a href="#"><?=$val['nav']?></a></li>
				<?php endforeach;?>
				</ul>
			</div>
			<?php endif; ?>
			<?php if($show_template):?>
			<div class="show_template">
				<?php
				// Link to nhung content template
				$subtemplates = $this->model_c1->find_by_nodeid($node['id']);
				?>
				<?php foreach($subtemplates as $val) :?>
				<?php
					$template_name = 'template/content_';
					if(!empty($val['para_value']) && ($val['para_name']!='file')){
						$template_name .= $val['temp']."_".$val['para_value'];
					}
					else{
						$template_name .= $val['temp'];
					}
					echo $this->load->view($template_name, array('content' => $val));
				?>
				<?php endforeach;?>
			</div>
			<?php endif; ?>
			<?php if($show_sublevel_template):?>
			<div class="show_sublevel_template">
				It's not implement
			</div>
			<?php endif; ?>
	<div class="clearfix"> </div>
</div>
<?php }}} ?>